<template>
  <div class="box">
    <div class="p-tit">
      <div class="p-tit-c">
        <div class="icon" @click="goback">
          <van-icon name="arrow-left" size="20px" color="#ffffff" />
        </div>
        <div class="icon" @click="goback">
          <van-icon name="close" size="20px" color="#ffffff" />
        </div>
      </div>
    </div>
    <div class="box1" ref="box">
      <div class="content">
        <div class="p-tit-img">
          <div class="p-tit-img-c">
            <img :src="arr.medium" alt="图片找不到了" class="img1" />
            <img src="@/assets/images/movie/point.png" class="img2" alt />
          </div>
        </div>
        <div class="p-con">
          <div class="p-con-c">
            <p class="p-con-pone">
              {{arr.title}} ({{arr.year}})
              <span class="sp1">{{arr.longtime}}</span>
            </p>
            <p class="p-con-ptwo">Pride & Prejudice</p>
            <p class="p-con-pthree">
              <van-rate v-model="arr.rating_average" allow-half readonly :size="22" />
              <span class="spn2" @click="go(arr.mId)">{{num}}</span> /10
              <van-icon name="chat-o" class="icon1" size="16px" />
              <van-icon name="star-o" class="icon2" size="16px" />
            </p>
            <div class="p-pair" @click="act">
              <p class="p-pone act">简介</p>
              <p class="p-pone" @click="revie">影评</p>
              <p class="p-pone">讨论</p>
              <p class="p-pone">更多</p>
            </div>
            <div class="p-summary">
              <p class="summary">{{arr.summary}}</p>
              <div>
                <div class="dots">
                  . . .
                  <span>查看更多 ></span>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="man">
          <div class="man-tit">演职人员</div>
          <div class="swps">
            <swiper ref="mySwiper" :options="swiperOptions">
              <swiper-slide
                v-for="ele in playes"
                :key="ele.id"
                class="swps1"
                @click="actors(ele.playerId)"
              >
                <img :src="ele.avatar" alt="图片找不到了" class="swimg" @click="actors(ele.playerId)" />
                <p class="swp1" @click="actors(ele.playerId)">{{ele.name[names]}}</p>
                <p class="swp2" @click="actors(ele.playerId)">{{ele.role}}</p>
              </swiper-slide>
              <!-- <div class="swiper-pagination" slot="pagination"></div> -->
            </swiper>
          </div>
          <p class="playnums">全部{{playes.length}}位演员</p>
        </div>
        <div class="p-advio">
          <div class="ad-tit">视频</div>
          <div class="ad-swps">
            <swiper ref="Swiper" :options="Options">
              <swiper-slide v-for="(ele,index) in movie " :key="index">
                <video :src="ele" controls preload="metadata" class="vid"></video>
              </swiper-slide>
              <!-- <div class="swiper-pagination" slot="pagination"></div> -->
            </swiper>
          </div>
          <p class="movnums">全部{{movie.length}}个视频</p>
        </div>
        <div class="p-money">
          <div class="mo-tit">票房</div>
          <div class="money-pone">
            <p class="pnum">2</p>
            <p>暂无</p>
            <p class="pyear">2660</p>
          </div>
          <div class="money-ptwo">
            <p>今日票房排行</p>
            <p>首周票房（万）</p>
            <p>今日票房排行</p>
          </div>
          <p class="mon-mon" @click="gos(arr.mId)">票房详情</p>
        </div>

        <van-button color="linear-gradient(to right, #F25B86, #F1AC5E)" class="btn">特惠选座</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import BScroll from "@better-scroll/core";
export default {
  data() {
    return {
      arr: {},
      num: "",
      names: 0,
      // id: 27119724,
      playes: [],
      movie: [],
      swiperOptions: {
        slidesPerView: 3.4,
        spaceBetween: 15,
        pagination: {
          el: ".swiper-pagination",
          clickable: true
        }
        // Some Swiper option/callback...
      },
      Options: {
        slidesPerView: 1.6,
        spaceBetween: 15,
        loop: true,
        pagination: {
          el: ".swiper-pagination",
          clickable: true
        }
        // Some Swiper option/callback...
      }
    };
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper;
    },
    swiper() {
      return this.$refs.Swiper.$swiper;
    }
  },
  created() {
    this.$axios
      .get("/api/douban/movie/subject", {
        params: {
          mId: this.$route.params.id
        }
      })
      .then(res => {
        this.arr = res.data;
        this.num = this.arr.rating_average;
        this.arr.rating_average = Math.round(this.arr.rating_average / 2);
        this.playes = res.data.players;
        this.movie = res.data.trailers;
        this.playes.forEach(ele => (ele.name = ele.name.split(" ")));

        console.log(this.playes);
        this.refresh();
      });
  },
  mounted() {
    let wrapper = this.$refs.box;
    this.bScroll = new BScroll(wrapper, {
      click: true
    });
  },
  methods: {
    //返回
    goback() {
      this.$router.go(-1);
    },
    //激活样式
    act() {
      if (event.target.tagName == "P") {
        document.querySelector(".act").classList.remove("act");
        event.target.classList.add("act");
      }
    },
    //跳转演员详情
    actors(val) {
      console.log(1);
      this.$router.push({
        name: "actor",
        params: {
          id: val
        }
      });
    },
    go(val) {
      // this.$router.push("/movie/point");
      this.$router.push({
        name: "rating",
        params: { id: val }
      });
      // this.$store.commit("mid", val);
    },
    gos(val) {
      this.$router.push({
        name: "office",
        params: { id: val }
      });
    },
    revie() {
      this.$router.push("/movie/review");
    },
    refresh() {
      this.$nextTick(() => {
        this.bScroll.refresh();
      });
    }
  }
};
</script>

<style scoped lang="scss">
.box1 {
  height: 743.5px;
}
.box {
  // // height: 100vh;
  // height: 100vh;
  background: #22262d;
  overflow: hidden;
}
.p-tit {
  width: 100%;
  height: 60px;
  background: #22262d;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99;
  overflow: hidden;
  .p-tit-c {
    width: 335px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    overflow: hidden;

    .icon {
      margin-top: 20px;
    }
  }
}
.p-tit-img {
  width: 100%;
  height: 131px;
  margin-top: 68px;
  // margin-bottom: 30px;
  background-color: #22262d;
  .p-tit-img-c {
    width: 250px;
    height: 100%;
    margin-left: 20px;
    background-color: #22262d;

    display: flex;
    justify-content: space-between;

    .img1 {
      width: 96px;
      height: 131px;
    }
    .img2 {
      width: 50px;
      height: 50px;
      align-self: center;
    }
  }
}
.p-con {
  width: 100%;
  // height: 230px;
  background-color: #22262d;
  margin-bottom: 30px;
  .p-con-c {
    width: 335px;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
    // display: flex;
    // justify-content: flex-start;
    .p-con-pone {
      font-size: 20px;
      font-weight: 500;
      color: rgba(255, 255, 255, 1);
      line-height: 15px;
      text-align: left;
      margin-top: 30px;
    }
    .sp1 {
      font-size: 12px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(241, 116, 121, 1);
      line-height: 12px;
      margin-left: 15px;
    }
    .p-con-ptwo {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: gray;
      line-height: 14px;
      text-align: left;
      margin-top: 15px;
    }
    .p-con-pthree {
      text-align: left;
      font-size: 12px;
      color: rgba(255, 255, 255, 1);
      line-height: 17px;
      // margin-bottom: 30.2px;
      margin-top: 10px;
    }
    .spn2 {
      font-size: 22px;
      font-weight: 500;
      color: rgba(251, 195, 74, 1);
      // line-height: 22px;
      margin-left: 14px;
    }
    .icon1 {
      margin-left: 88px;
    }
    .icon2 {
      margin-left: 17px;
    }
  }
}
.p-pair {
  display: flex;
  justify-content: flex-start;
  margin-top: 30px;

  .p-pone {
    font-size: 14px;
    color: grey;
    line-height: 14px;
    margin-right: 30px;
  }
  .act {
    color: #ffffff;
  }
  .act::after {
    content: "";
    display: block;
    width: 29px;
    height: 3px;
    background: linear-gradient(
      135deg,
      rgba(241, 100, 129, 1) 0%,
      rgba(241, 144, 108, 1) 100%
    );
    margin-top: 3px;
  }
}
.p-summary {
  width: 330px;
  height: 72px;
  overflow: hidden;
  position: relative;
  margin-top: 9px;
}
.summary {
  width: 330px;
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.29);
  line-height: 18px;
  // text-indent:-18px;
}
.dots {
  position: absolute;
  bottom: 0px;
  right: 0px;
  font-size: 14px;
  line-height: 18px;
  z-index: 99;
  height: 17px;
  width: 102px;
  background: #22262d;
  color: rgba(255, 255, 255, 0.29);
  line-height: 14px;
  text-align: left;
  span {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(251, 195, 74, 1);
    line-height: 14px;
  }
}
.man {
  width: 335px;
  margin: 0 auto;
  // overflow: hidden;
  .man-tit {
    width: 72px;
    height: 18px;
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    line-height: 18px;
    margin-bottom: 15px;
  }
}
.swps {
  width: 375px;
  margin: 0 auto;
}
// body .swiper-slide {
//   overflow: hidden;
// }
.swimg {
  width: 100px;
  height: 140px;
  border-radius: 8px;
  position: relative;
  z-index: 99;
}
.swp1 {
  width: 89px;
  height: 14px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  line-height: 14px;
  margin-top: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.swp2 {
  width: 89px;
  height: 12px;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  line-height: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  margin-top: 7px;
}
.playnums {
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(251, 195, 74, 1);
  line-height: 14px;
  margin-top: 15px;
  margin-bottom: 30px;
}
.ad-tit {
  width: 72px;
  height: 18px;
  font-size: 18px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  line-height: 18px;
  margin-bottom: 15px;
}
.vid {
  width: 200px;
  height: 120px;
  //  border-radius: 4px;
}
.movnums {
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(251, 195, 74, 1);
  line-height: 14px;
  margin-top: 15px;
  // margin-bottom: 30px;
}
.ad-swps {
  width: 335px;
  height: 120px;
  margin: 0 auto;
}
.p-money {
  width: 335px;
  margin: 0 auto;
  .mo-tit {
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    line-height: 18px;
    text-align: left;
  }
  .money-pone {
    width: 335px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    color: rgba(255, 255, 255, 1);
    line-height: 18px;
    margin-top: 17px;
    .pnum {
      margin-left: 31px;
    }
    .pyear {
      margin-right: 14px;
    }
  }
  .money-ptwo {
    width: 335px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #474b51;
    line-height: 12px;
    margin-top: 6px;
  }
  .mon-mon {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(251, 195, 74, 1);
    line-height: 14px;
    margin-top: 15px;
    text-align: center;
  }
}
.btn {
 
  width: 101%;
  height: 44px;
  margin-top: 22px;
  font-size: 18px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: rgba(255, 255, 255, 1);
  line-height: 18px;
}
.swps1 {
  width: 100%;
  height: 100%;
}
</style>
